IMAGE_NAME := government-regulatory-platform
DNAME := $(shell dirname $(shell pwd))

# 编译版本号
OLD_BUILD_NUMBER := ${shell tail buildNumber}
BUILD_NUMBER := $(shell expr ${OLD_BUILD_NUMBER} + 1)

# 主版本号
MAJOR_NUMBER := 1
# 子版本号
MINOR_NUMBER := $(shell expr ${BUILD_NUMBER}  / 100)
# 修正版本号
REVISION_NUMBER := $(shell expr ${BUILD_NUMBER}  % 100)

VERSION := ${MAJOR_NUMBER}.${MINOR_NUMBER}.${REVISION_NUMBER}
BUILD_TIME := $(shell date '+%Y-%m-%d_%H:%M:%S')
COMMIT_ID := $(shell git rev-parse --short HEAD || echo unsupported)

HW_AK  := YNTZFGVUD2NZEEG5JKBX
HW_PWD := ''


release:
	npm run build:prod
	echo $(shell expr ${BUILD_NUMBER} + 1) > buildNumber

release-docker: release
	docker image prune -f
	docker build -f docker/release.Dockerfile -t $(IMAGE_NAME):$(VERSION) .
	docker save $(IMAGE_NAME):$(VERSION) > bin/$(IMAGE_NAME)-$(VERSION).tar

release-to-hw: release
	docker image prune -f
	docker build -f docker/release.Dockerfile -t $(IMAGE_NAME):$(VERSION) .
	docker login -u cn-east-2@$(HW_AK) -p $(HW_PWD) swr.cn-east-2.myhuaweicloud.com
	docker tag $(IMAGE_NAME):$(VERSION) swr.cn-east-2.myhuaweicloud.com/hw_17798526102/$(IMAGE_NAME):$(VERSION)
	docker push swr.cn-east-2.myhuaweicloud.com/hw_17798526102/$(IMAGE_NAME):$(VERSION)
